/*
 *
 */
package org.jiscinvolve.astrodabis.barberry.common.data;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.net.URI;

import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import static org.junit.Assert.*;

/*
 *
 */
public class TapServiceTestCase
extends DataTestBase
    {

    @Test
    public void checkCreatedNotNull()
        {
        TapService created = womble().services().create(
            unique(
                URI.create(
                    "ivo://org.astrodabis.test/service/"
                    )
                ),
            "test-service"
            );
        assertNotNull(
            created
            );
        }    

    @Test
    public void checkCreatedIdentNotNull()
        {
        TapService created = womble().services().create(
            unique(
                URI.create(
                    "ivo://org.astrodabis.test/service/"
                    )
                ),
            "test-service"
            );
        assertNotNull(
            created.ident()
            );
        }    

    @Test
    public void checkCreatedIvornNotNull()
        {
        TapService created = womble().services().create(
            unique(
                URI.create(
                    "ivo://org.astrodabis.test/service/"
                    )
                ),
            "test-service"
            );
        assertNotNull(
            created.ivorn()
            );
        }    

    @Test
    public void checkSelectByIdent()
        {
        TapService created = womble().services().create(
            unique(
                URI.create(
                    "ivo://org.astrodabis.test/service/"
                    )
                ),
            "test-service"
            );
        TapService selected = womble().services().select(
            created.ident()
            );
        compare(
            created,
            selected
            );
        }    

    @Test
    public void checkSelectByIvorn()
        {
        TapService created = womble().services().create(
            unique(
                URI.create(
                    "ivo://org.astrodabis.test/service/"
                    )
                ),
            "test-service"
            );
        TapService selected = womble().services().select(
            created.ivorn()
            );
        compare(
            created,
            selected
            );
        }    

/*
 * These fail because the database is not empty ..
    @Test
    public void checkSelectAll()
        {
        assertNotNull(
            womble().services().select()
            );
        assertNotNull(
            womble().services().select().iterator()
            );
        assertFalse(
            womble().services().select().iterator().hasNext()
            );
        assertNotNull(
            womble().services().create(
                unique(
                    URI.create(
                        "ivo://org.astrodabis.test/service/"
                        )
                    )
                )
            );
        assertTrue(
            womble().services().select().iterator().hasNext()
            );
        }

    @Test
    public void checkSelectAllCount()
        {
        for (int count = 1 ; count <= 10 ; count++)
            {
            womble().services().create(
                unique(
                    URI.create(
                        "ivo://org.astrodabis.test/service/"
                        )
                    )
                );
            assertEquals(
                count,
                count(
                    womble().services().select()
                    )
                );
            }
        }
 */


    }

